﻿<!doctype html>
<html>
<head>
    <meta charset="utf-8">

    <title>定时器内this问题</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
            font-family: "微软雅黑", "张海山锐线体简";
        }

    </style>
    <script>
        function Login() {
            this.a = 1;
            this.obj = {
                h: 'hello',
                w: 'world'
            };
            this.alert = this.alert.bind(this);
            console.log(this);
        }

        Login.prototype.alert = function () {
            console.log(this);
            console.log(this.a);
        };
        var l = new Login();

        l.alert();
    </script>
</head>

<body>

<input type="button" value="按钮" id="btn1">

</body>
</html>
